package db

import (
	"fmt"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/postgres"
)

type PostgreSQLConfig struct {
	Dber
	Host     string
	Port     string
	Database string
	Username string
	Password string
	Charset  string
}

func (c *PostgreSQLConfig) Connect() *gorm.DB {
	connectString := fmt.Sprintf("host=%s port=%s user=%s dbname=%s password=%s", c.Host, c.Port, c.Username, c.Database, c.Password)
	db, err := gorm.Open("postgres", connectString)
	if err != nil {
		panic(err)
	}

	return db
}
